package weak_20241227_29.io;

import java.io.*;

/**
 * @author zdl
 * @date 2024/12/28
 */
public class Demo12 {
    public static void main(String[] args) throws IOException {
        //12. 编写一个Java程序，读取一个文本文件的内容，并将其内容反转后写入到另一个文件。
        BufferedReader br = new BufferedReader(new FileReader("D:/test/old.txt"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("D:/test/reverse.txt"));
        String len;
        while ((len = br.readLine()) != null) {
            String s = new StringBuilder(len).reverse().toString();
            System.out.println(s);
            bw.write(s);
            bw.newLine();
        }
        bw.close();
        br.close();
    }
}
